package Baitap;
import java.util.*;
public class Sinhvien {	
		private String ten;
		private int ms;
		private double diem;
		public Sinhvien(){}
		public String getTen() {
			return ten;
		}
		public void setTen(String ten) {
			this.ten = ten;
		}
		public int getMs() {
			return ms;
		}
		public void setMs(int ms) {
			this.ms = ms;
		}
		public double getDiem() {
			return diem;
		}
		public void setDiem(double diem) {
			this.diem = diem;
		}
public void nhap(){
		Scanner sc = new Scanner(System.in);
		System.out.print("Nhap ten: ");
		this.ten=sc.nextLine(); 
		System.out.print("Nhap ma so sinh vien: ");
		this.ms=sc.nextInt(); sc.nextLine();
		System.out.print("Nhap diem: ");
		this.diem=Double.parseDouble(sc.nextLine()); 
	}
public void hienthi(){	
	System.out.printf("\t\n| %s  \t|   %d   \t|   %f  \t|",this.ten,this.ms,this.diem);
	
}	
		public static void main(String[] args){
			int sl;
			Sinhvien sv[]=new Sinhvien[10];
			Scanner sc= new Scanner(System.in);			
			System.out.print("Nhap so sinh vien: ");
            sl=sc.nextInt();   sc.nextLine();        
            for(int i=1;i<=sl;i++){
            sv[i-1]=new Sinhvien();
            System.out.println("Nhap vao thong tin sinh vien thu: "+i);
           	sv[i-1].nhap();}
            System.out.println("\nThong tin cac sinh vien vua nhap: ");
            for(int i=1;i<=sl;i++){
           	sv[i-1].hienthi();
            }
			double tongdiem=0;
			for(int i=1;i<=sl;i++)
				tongdiem=tongdiem+sv[i-1].diem;
				double tb;
				tb=tongdiem/sl;			
			System.out.println("\ndiem trung binh cua cac sinh vien la: "+tb );
		    double temp;
		    temp=sv[0].diem;
		    for(int i=1;i<sl;i++)
		    	if(temp<sv[i].diem)
		    		temp=sv[i].diem; 
		    System.out.println("sinh vien co diem cao nhat la: ");
		    for(int j=0;j<sl;j++)
		    	if(sv[j].diem==temp)
		    		System.out.println(sv[j].ten);	
		    temp=sv[0].diem;
		    for(int i=1;i<sl;i++)
		    	if(temp>sv[i].diem)
		    		temp=sv[i].diem;
		    System.out.println("Sinh vien co diem thap nhat la: ");
		    for(int i=0;i<sl;i++)
		    	if(sv[i].diem==temp)
		    		System.out.println(sv[i].ten);
		    int cout=0;
		    for(int i=0;i<sl;i++)
		    	if(sv[i].diem>=4) cout++;
		    System.out.print("So sinh vien co diem dat(>=4) la: "+cout);
		}
	}
	

		




